package data;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class EchoTemplate implements Serializable {
	private int time; // milliseconds
	private int feedback; // 0 - 100?
	private int sync;
	
	public EchoTemplate() {
		time = 0;
		feedback = 0;
		sync = 0;
	}
	
	public EchoTemplate(int time, int feedback,  int sync) {
		this.time = time;
		this.feedback = feedback;
		this.sync = sync;
	}
	
	public int getTime() {
		return time;
	}
	
	public int getFeedback() {
		return feedback;
	}
	
	public int getSync() {
		return sync;
	}
	
	public void setTime(int time) {
		this.time = time;
	}
	
	public void setFeedback(int feedback) {
		this.feedback = feedback;
	}

	public void setSync(int sync) {
		this.sync = sync;
	}
	
	@Override
	public void serialize(OutputStream os) {
		try {
			//os.write(3);
			os.write(time);
			os.write(feedback);
			os.write(sync);
			System.out.println("" + time);
			System.out.println("" + feedback);
			System.out.println("" + sync);
		} 
		catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	@Override
	public void deserialize(InputStream is) {
		try {
			time = is.read();
			feedback = is.read();
			sync = is.read();
			System.out.println(time + " " + feedback + " " + sync);
		} 
		catch (IOException ioe) {
			ioe.printStackTrace();
		}
		
	}
	@Override
	public String toString() {
		return "" + time + " " + feedback + " " + sync;
	}
}
